package com.neusoft.neuiotms.dcom.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.dcom.model.enums.MaintainPlanStatus;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_maintain_plan")
@org.hibernate.annotations.Table(appliesTo = "neuiot_maintain_plan", comment = "维护计划表")
public class MaintainPlan extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @Length(max = 50, message = "计划编码不能超过{max}位")
    @Column(length = 50, nullable = false)
    @Comment("varchar(50) NOT NULL COMMENT '计划编码'")
    private String code;

    @NotBlank(message = "计划名称")
    @Length(max = 100, message = "名称不能超过{max}位")
    @Column(length = 100, nullable = false)
    @Comment("varchar(100) NOT NULL COMMENT '计划编码'")
    private String name;

    @Comment("int NULL COMMENT '维护规则'")
    @ManyToOne
    private MaintainRule rule;

    @NotBlank(message = "部门编码")
    @Length(max = 50, message = "部门编码不能超过{max}位")
    @Column(length = 50, nullable = false)
    @Comment("varchar(50) NOT NULL COMMENT '部门编码'")
    private String orgCode;

    @Length(max = 100, message = "部门名称不能超过{max}位")
    @Column(length = 100, nullable = true)
    @Comment("varchar(100) NULL COMMENT '部门名称'")
    private String orgName;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("text COMMENT '对象编码集合'")
    private String jsonObjs;

    @Length(max = 25, message = "周期不能超过{max}位")
    @Column(length = 25, nullable = false)
    @Comment("varchar(25) NULL COMMENT '周期'")
    private String period;

    @Comment("BIGINT NOT NULL COMMENT '执行人ID'")
    private Long chargeUserId;

    @Length(max = 100, message = "执行人name不能超过{max}位")
    @Column(length = 100, nullable = false)
    @Comment("varchar(100) NULL COMMENT '执行人name'")
    private String chargeUserName;

    @Length(max = 100, message = "执行人username名称不能超过{max}位")
    @Column(length = 100, nullable = false)
    @Comment("varchar(100) NULL COMMENT '执行人名称'")
    private String chargeUserCode;

    @Comment("BIGINT NOT NULL COMMENT '申请人编码'")
    private Long userId;

    @Length(max = 100, message = "申请人名称不能超过{max}位")
    @Column(length = 100, nullable = true)
    @Comment("varchar(100) NULL COMMENT '申请人名称'")
    private String userName;

    @Enumerated(EnumType.STRING)
    @Column(length = 25, nullable = false)
    @Comment("varchar(25) NOT NULL COMMENT '计划状态'")
    private MaintainPlanStatus status = MaintainPlanStatus.created;

    @Comment("BIGINT NOT NULL COMMENT '版本'")
    private Long version = 1L;

    @Comment("bit(1) COMMENT '删除标志，0：未删除，1：已删除'")
    private boolean deleteFlag = false;
}
